//
//  LVEncounterAndPropVc.m
//  LEVE
//
//  Created by 上官惠阳 on 2017/3/7.
//  Copyright © 2017年 dashuju. All rights reserved.
//

#import "LVEncounterAndPropVc.h"
#import "HYCustomCommonEmptyView.h"
#import "LVIssueAndReceiveCell.h"
#import "LVSessionCell.h"
#import "LVCustomAlertView.h"

@interface LVEncounterAndPropVc ()
@property (nonatomic, weak) HYCustomCommonEmptyView *emptyView;
@end

@implementation LVEncounterAndPropVc

- (void)viewDidLoad {
    [super viewDidLoad];

    self.refreshType = HYBaseTableVcRefreshTypeRefreshAndLoadMore;

    [self loadData];
}
- (void)loadData
{
    [self.dataArray addObject:@[@"",@"",@"",@""]];
    [self.dataArray addObject:@[@"",@"",@""]];
    [self.dataArray addObject:@[@"",@""]];

    if (!self.dataArray.count) {
        [self.emptyView showInView:self.view];
    }else{
        [self.emptyView removeFromSuperview];
    }

    [self HY_reloadData];
}
#pragma mark refresh
- (void)HY_refresh
{
    [super HY_refresh];

    [self.dataArray removeAllObjects];
    [self loadData];

    [self HY_endRefresh];
}
- (void)HY_loadMore
{
    [super HY_loadMore];

    [self loadData];

    [self HY_endLoadMore];
}
#pragma mark - UITableViewDelegate
- (NSInteger)HY_numberOfSections {
    return self.dataArray.count;
}

- (NSInteger)HY_numberOfRowsInSection:(NSInteger)section {
    return [self.dataArray[section] count];
}

- (HYBaseTableViewCell *)HY_cellAtIndexPath:(NSIndexPath *)indexPath {

    LVIssueAndReceiveCell *cell = [LVIssueAndReceiveCell nibCellWithTableView:self.tableView];
    if (indexPath.section%3 == 0) {
        cell.stateType = LVImpStateBanana;
    }else if (indexPath.section%3 == 1){
        cell.stateType = LVImpStateNone;
    }else{
        cell.stateType = LVImpStateNone;
    }
    [cell addLongPressWithBlock:^(id obj) {
        LVCustomAlertView *alert = [[LVCustomAlertView alloc] initWithTitle:@"你确定要删除这条动态吗？" cancel:@"取消" sure:@"确认"];
        [alert showInView:self.view.window];
        WeakSelf(weakSelf);
        [alert setupSureBlock:^BOOL{

            return YES;
        }];
        [alert setupCancelBlock:^BOOL{


            return YES;
        }];
    }];
    return cell;
}

- (CGFloat)HY_cellheightAtIndexPath:(NSIndexPath *)indexPath {
    return 65;
}
- (UIView *)HY_headerAtSection:(NSInteger)section
{
    LVSessionCell *sessionView = [LVSessionCell nibCellWithTableView:self.tableView];
    sessionView.backgroundColor = [UIColor whiteColor];
    sessionView.leftTitleLabel.textColor = KGrayColor;
    sessionView.leftTitleLabel.text = @"二月20号 18:30";
    sessionView.leftTitleLabel.font = [UIFont systemFontOfSize:13];
    sessionView.rigthBtn.hidden = YES;
    return sessionView;
}
- (CGFloat)HY_sectionHeaderHeightAtSection:(NSInteger)section
{
    return 35;
}
#pragma mark emptyView
- (HYCustomCommonEmptyView *)emptyView {
    if (!_emptyView) {
        HYCustomCommonEmptyView *empty = [[HYCustomCommonEmptyView alloc] initWithTitle:@"暂无动态" secondTitle:@"" iconname:@"无动态"];
        [self.view addSubview:empty];
        _emptyView = empty;
    }
    return _emptyView;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
